---
- name: Check if cargo is installed
  ansible.builtin.command: command -v cargo
  register: cargo_exists
  ignore_errors: true
  changed_when: false
  tags:
    - rust

- name: Download Installer
  when: cargo_exists is failed
  ansible.builtin.get_url:
    url: https://sh.rustup.rs
    dest: /tmp/sh.rustup.rs
    mode: "0755"
    force: "yes"
  tags:
    - rust

- name: Install rust/cargo
  when: cargo_exists is failed
  ansible.builtin.command: /tmp/sh.rustup.rs -y
  tags:
    - rust
